package com.offcn.controller;

import com.offcn.entity.Address;
import com.offcn.entity.User;
import com.offcn.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;
    @PostMapping("/")
    public int add(@RequestBody User user){
        userService.add(user);
        return 1;
    }

    @DeleteMapping("/{id}")
    public int delete(@PathVariable int id){
        userService.delete(id);
        return 1;
    }

    @GetMapping("/")
    public List<User> select(){
        List<User> list = userService.select();
        return list;
    }

    @PutMapping("/")
    public int update(@RequestBody Address address){
        userService.update(address);
        return 1;
    }
}
